<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
if (!is_numeric($_GET['ID'])) {MsgBox (1,'ID参数出现非数字错误！','-1');}
$nLink = $db->SelectSQL("SELECT `LinkType`,`LinkWebName`,`LinkWebUrl`,`LinkWebIntro`,`LinkLogoUrl`,`LinkWebAdmin`,`LinkEmail`,`LinkSort`,`LinkIsAudit`,`LinkTime` FROM `" . $dbprefix . "link` WHERE `ID` = '" . $_GET['ID'] . "'");
if(count($nLink)==0){MsgBox (1,'不存在的新闻！','-1');}
Html($nLink[0]);
if($_POST['Action']=='UpDate'){

	$logo_url = $_POST['LinkLogoUrl'];
	if(!empty($_FILES['uplogo']['tmp_name'])){
		$up = new upload();
		$up -> field_name = 'uplogo';
		$up -> save_dir = '../uploadfile/Links/';
		$up -> ispics = true;
		$up -> save_son_dir = false;
		if($up->perform()){
			$logo_url = str_replace('../','',$up->URL);
		} else {
			AdminLog(2,$Lang,'添加友情链接失败！上传Logo出错。'); 
			MsgBox (1,'添加友情链接失败！上传Logo出错：'.$up->info,'-1');
		}
	}
	
	$SQL = "UPDATE `" . $dbprefix . "link` SET 
	`LinkType` = '" . $_POST['LinkType'] . "',
	`LinkWebName` = '" . $_POST['LinkWebName'] . "',
	`LinkWebUrl` = '" . $_POST['LinkWebUrl'] . "',
	`LinkWebIntro` = '" . $_POST['LinkWebIntro'] . "',
	`LinkLogoUrl` = '" . $logo_url . "',
	`LinkWebAdmin` = '" . $_POST['LinkWebAdmin'] . "',
	`LinkEmail` = '" . $_POST['LinkEmail'] . "',
	`LinkSort` = '" . $_POST['LinkSort'] . "',
	`LinkIsAudit` = '" . $_POST['LinkIsAudit'] . "'	
	WHERE `ID` = '" . $_GET['ID'] . "' LIMIT 1;";
	if($db->ExecuteSQL($SQL)){
		AdminLog(1,$Lang,'修改友情链接,结果：操作成功！'); 
		MsgBox (1,'友情链接修改成功！','LinkManage.php?Lang=' . $Lang . '&page=' . $_GET['page']);
	} else {
		AdminLog(1,$Lang,'修改友情链接,结果：操作失败！'); 
		MsgBox (1,'操作失败，请检查您提交的数据是否正确！','-1');
	}	
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link href="../tools/highslide/highslide.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
<script src="../tools/highslide/highslide.js" type="text/javascript"></script>
<script language="javascript">
function Check() {
	if (document.form1.LinkWebName.value==""){
		alert("请填写网站名称！");
		document.form1.LinkWebName.focus();
		return false;
	}
	if (document.form1.LinkWebUrl.value=="http://" || document.form1.LinkWebUrl.value==""){
		alert("请填写链接地址！");
		document.form1.LinkWebUrl.focus();
		return false;
	}
	if(document.form1.LinkSort.value.match(/^[0-9]\d*$/)==null){ 
		alert("排序字段必须为数字！"); 
		document.form1.LinkSort.focus(); 
		return false; 
	}	
}
hs.graphicsDir = '../tools/highslide/graphics/';
hs.showCredits = false;
hs.outlineType = 'rounded-white';
hs.restoreTitle = '关闭';
</script>	
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd">
	<td>&nbsp;</td>
	<td align="right">
		<input type="button" value="添加链接" onClick="javascript:location.href='LinkAdd.php?Lang=<?php echo $Lang?>'">
		<input type="button" value="链接管理" onClick="javascript:location.href='LinkManage.php?Lang=<?php echo $Lang?>'">	
	</td>
	</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <form id="form1" name="form1" method="post" action="LinkUpDate.php?Lang=<?php echo $Lang?>&page=<?php echo $_GET['page']?>&ID=<?php echo $_GET['ID']?>" onSubmit="return Check()" enctype="multipart/form-data">
  <tr>
    <td colspan="3" align="center" class="Main_Title">修改友情链接<?php echo $OnWebLangName?></td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">
    链接类型：</td>
    <td><input name="LinkType" type="radio" id="radio" value="0" <?php if($nLink[0][0]==0) echo 'checked="checked"';?> />
      文字链接
      <input type="radio" name="LinkType" id="radio2" value="1" <?php if($nLink[0][0]==1) echo 'checked="checked"';?> />
      Logo链接</td>
    <td class="ippv">请选择前台支持的链接类型</td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">网站名称：</td>
    <td><input name="LinkWebName" type="text" class="input2" id="LinkWebName" maxlength="30" value="<?php echo $nLink[0][1]?>" />
      <span class="red">*</span></td>
    <td class="ippv">&nbsp;</td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">链接地址：</td>
    <td><input name="LinkWebUrl" type="text" class="input2" id="LinkWebUrl" value="<?php echo $nLink[0][2]?>" maxlength="200" />
      <span class="red">*</span></td>
    <td class="ippv">格式：<span class="Igreen">http://www.SongCMS.com</span></td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">上传Logo：</td>
    <td><input name="uplogo" id="uplogo" type="file" /></td>
    <td class="ippv">
<?php
strtolower(substr($nLink[0][4],0,7)) != 'http://' ? $LinkLogoUrl = '../' . $nLink[0][4] : $LinkLogoUrl = $nLink[0][4];
if($nLink[0][4]!='')echo '<a href="' . $LinkLogoUrl . '" onclick="return hs.expand(this);">Logo已存在(预览)</a>,不更换图片时不用上传,上传将会替换当前Logo';?></td>
  </tr>
  <tr class="odd">
  	<td height="20" align="right">Logo址址：</td>
  	<td><input name="LinkLogoUrl" type="text" id="LinkLogoUrl" size="50" maxlength="100" value="<?php echo $nLink[0][4]?>" /></td>
  	<td class="ippv"></td>
  	</tr>
  <tr class="odd">
    <td height="20" align="right">网站管理员：</td>
    <td><input name="LinkWebAdmin" type="text" class="input2" id="LinkWebAdmin" maxlength="30" value="<?php echo $nLink[0][5]?>" /></td>
    <td class="ippv">&nbsp;</td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">联系E-Mial：</td>
    <td><input name="LinkEmail" type="text" class="input2" id="LinkEmail" maxlength="50" value="<?php echo $nLink[0][6]?>" /></td>
    <td class="ippv">&nbsp;</td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">网站简介：</td>
    <td><textarea onpropertychange="if(value.length>255) value=value.substr(0,255)" name="LinkWebIntro" cols="28" rows="4" id="LinkWebIntro" style="width:200px;"><?php echo $nLink[0][3]?></textarea></td>
    <td class="ippv">不得超过255个字符</td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">排序：</td>
    <td><input name="LinkSort" type="text" id="LinkSort" value="<?php echo $nLink[0][7]?>" size="4" maxlength="6" /></td>
    <td class="ippv">降序(倒序)，值越大排列越靠前</td>
  </tr>
  <tr class="odd">
    <td height="20" align="right">通过审核：</td>
    <td><input name="LinkIsAudit" type="radio" id="radio3" value="1" <?php if($nLink[0][8]==1) echo 'checked="checked"';?> />
      是
        <input type="radio" name="LinkIsAudit" id="radio4" value="0" <?php if($nLink[0][8]==0) echo 'checked="checked"';?> />
      否</td>
    <td class="ippv">未通过审核的链接将不在前台显示</td>
  </tr>
  <tr class="odd">
    <td align="right">&nbsp;</td>
    <td><input type="submit" name="button" id="button" value="修 改" class="submit" />
      &nbsp;&nbsp;&nbsp;&nbsp;
      <input name="Action" type="hidden" id="Action" value="UpDate" />      
      &nbsp;&nbsp;&nbsp;&nbsp;
      <input type="reset" name="button2" id="button2" value="重 置" class="submit" /></td>
    <td class="ippv">添加时间：<?php echo $nLink[0][9]?></td>
  </tr>
    </form>
  </table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;"></td>
	</tr>
</table>  
</body>
</html>
